
Balloons
DownloadAn eternal line of balloons rise toward their death.
They evade my hand running to the blaze.
Updates
2025-05-16 - A few things:
- masonry_direction is an option now and can be set to 'horizontal','vertical', or 'both'.
- grid_card_layout and view_card_layout accept an array with any mix of the following: 'image', 'title', 'download', 'tags', 'description'; customize how cards look. (grid_card_layout can accept but does nothing with 'download')
- Added a button to example to toggle Deviant Art theme on and off2025-05-05 - The CSS looks like DeviantArt now. There is a reason, but I will not give it. Example Page now includes a header, nav, and footer, however these are not included in the script.
2025-05-04 - Videos should work probably
2025-04-25 - Avoiding multiple tags should work now
Skip the intro:
Hello there, I am here. Ignoring my very important work, as always, to bring something I spent much too long making! The other day I saw a reddit post asking for an easy solution to image galleries, one that would require minimal coding as the asker was afraid they'd mess up badly during an edit.
Honestly, I get it. It's why do_blog even exists (not to mention I'm too lazy to update a whole page everytime I write a blog post >.>) Anyway, I recommended do_blog for the job, but it was understandably a little too specifically a blog script.
One thing led to one thing and now here I am, presenting Gallery! Check out the example below:
I will not explain why the example looks like DeviantArt further than I needed to de-stress after finals. The example page includes a toggle button to turn this theme off and on. In Customize you'll find options to change the grid layout to masonry or to make it look less organized.
Other examples:
Inline example without CSS:
<script src="gallery.js" defer></script> <div name=gallery></div> <pre name=archive hidden> gifs/fish/aquarium.gif # fish,tag caption: This is a GIF image of a fish tank. The fish don't move, so I fear they may be dead, but the clam is breathing, so it's probably just eating supper. Nom nom nom fish breakfast. title: Fishy fish gifs/fish/aquarium2.gif # fish,tag gifs/fish/aquarium3.gif # fish gifs/balloons.gif # red, yellow, blue, green gifs/bike.gif # yellow gifs/birdbath.gif # birb, blue, yellow, green gifs/cartooncarousel.gif # blue, red, pink gifs/lantern.gif # orange, yellow gifs/maracacactus.gif # green, yellow </pre>
gifs/fish/aquarium.gif # fish,tag caption: This is a GIF image of a fish tank. The fish don't move, so I fear they may be dead, but the clam is breathing, so it's probably just eating supper. Nom nom nom fish breakfast. title: Fishy fish gifs/fish/aquarium2.gif # fish,tag gifs/fish/aquarium3.gif # fish gifs/balloons.gif # red, yellow, blue, green gifs/bike.gif # yellow gifs/birdbath.gif # birb, blue, yellow, green gifs/cartooncarousel.gif # blue, red, pink gifs/lantern.gif # orange, yellow gifs/maracacactus.gif # green, yellow
Note, the masonry layout is now opt-in, not opt-out.
In the element with name=archive
, you create objects in the following format:
path/to/image.jpg
# tag, comma separated, other tag
attribute=content
key: value
path/to/image.jpg
is what would normally be the src
in the img
element.
You can tag images either using #
or tags:
The difference between key: value
and attribute=content
is that attributes are your typical HTML attributes!
There are three important "keys" to have in mind, other than the tags one: title
and caption
.
title: Title of Image
caption: A description that can be super long or super short.
You can go to the next line if you want, it'll start a new paragraph, but don't skip a line or it'll stop capturing the caption.
<strong>You may use HTML here.</strong>
isYoutube: true
Instead of caption
, you can also use description
or details
, but at the end of the day it's the same paragraph.
Don't include isYoutube
at all if you're not linking a youtube video. To properly embed a YouTube video, click on the "Share" button under the video, then go to "Embed" and copy the given iframe's src
URL.
There are two attributes that do not affect the image directly:
class=class1 class2 class-3
title=lil popup thing
The classes are added to the "card" article that holds the image, so if you wanted to reference the image in your CSS with that class, you'd look for .class img
.
The title
attribute is that little popup that sometimes appears when you hover over links, and that affects the "View" and "Download" links.
Otherwise, attributes will affect the image. Don't add quotation marks!
An example of an image:
<pre name=archive hidden>
gifs/balloons.gif
# red, yellow, blue, green
title: Balloons
caption:
An eternal line of balloons rise toward their death.
They evade my hand running to the blaze.
class = balloony float
width=200
height=200
</pre>
<div name=gallery></div>
Which should result in:
<pre name=archive hidden>(…)</pre>
<div name=gallery>
<article id="image-gifs-balloons-gif" class="card balloony float">
<img src="gifs/balloons.gif" width="200" height="200">
<h1 class="title">Balloons</h1>
<ul class="taglist">
<li class="tag"><a href="?find=red">red</a></li>
<li class="tag"><a href="?find=yellow">yellow</a></li>
<li class="tag"><a href="?find=blue">blue</a></li>
<li class="tag"><a href="?find=green">green</a></li>
</ul>
<a href="gifs/balloons.gif" download="balloons.gif" class="download"><span>Download</span></a>
<div class="caption">
<p>An eternal line of balloons rise toward their death.</p>
<p>They evade my hand running to the blaze.</p>
</div>
</article>
</div>
Which looks like:
There's not much to customize in this one. And I think the options are pretty self-explanatory! To customize, make an object called GALLERY
like so:
<script>
GALLERY = {
path: '',
masonry: 0,
masonry_direction: 'vertical',
images_per_page: 24,
max_width: '50vw',
max_height: '50vw',
min_width: '180px',
max_width: '180px',
grid_gap: 24,
max_pagination_links: 9,
grid_card_layout:
['image','title','tags'],
view_card_layout:
['image','title','tags','download','description']
}
</script>
path: ''
masonry: 0
1
or true
to turn it on.
masonry_direction: 'vertical'
'vertical'
, 'horizontal'
, and 'both'
. Though the first two options indeed work appropriately, using 'both'
makes the "cards" look scattered (very fun, but looks unorganized).
images_per_page: 24
max_width: '50vw'
max_height: '50vw'
min_width: '180px'
min_height: '180px'
grid_gap: 24
max_pagination_links: 9
0
or 1
.
grid_card_layout: ['image','title','tags']
view_card_layout: ['image','title','tags','download','description']
'image' – the image
,
'title' – the image title
,
'tags' – a list of tags
,
'download' – a download link
,
'description' – the caption
.
'download'
does not show up in the search page.
GALLERY
object):
Find_tags: 'Find tag(s): ',
Search_mode: 'Search mode: ',
Search_OR: 'OR',
Search_AND: 'AND',
Avoid_tags: 'Avoid tag(s): ',
Showing_results: ['Showing results ',' of '],
See_all_tags: 'See all tags',
Prev_page: 'Prev',
Page: 'Page: ',
Next_page: 'Next',
Prev_result: '← Prev',
Return_to_gallery: 'Gallery',
Next_result: 'Next →',
Permalink: 'View',
Download: 'Download',
No_description: '<p><i>No description</i>.</p>',